package com.chanzany.memento.improve;

/**
 * @Author ChanZany
 * @Date 2021/10/19 19:14
 * @Version 1.0
 */
public class PrototypeMemento {
    public static void main(String[] args) {
        OriginatorPrototype or = new OriginatorPrototype();
        PrototypeCaretaker cr = new PrototypeCaretaker();
        or.setState("S0");
        System.out.println("初始状态："+or.getState());
        cr.setMemento(or.createMemento());  //保存状态

        or.setState("S1");
        System.out.println("新的状态："+or.getState());

        or.restoreMemento(cr.getMemento());
        System.out.println("恢复状态："+or.getState());

    }
}
